package br.org.pmjn.patrimonio.core.infrastructure.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import br.org.pmjn.patrimonio.core.domain.bem.Bem;
import br.org.pmjn.patrimonio.core.domain.bem.BemRepository;

public class BemRepositoryImpl extends HibernateDaoSupport implements BemRepository{

	@Override
	public void salvar(Bem bem) {
		getHibernateTemplate().persist(bem);
	}

	@Override
	public void atualizar(Bem bem) {
		getHibernateTemplate().merge(bem); 
	}

	@Override
	public Bem localizarPorCodigo(Integer codigo) {
		
		return getHibernateTemplate().get(Bem.class, codigo);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Bem> listarTodos() {	
		return getSession().createCriteria(Bem.class).list();
	}

}
